In October 2012, the US government's Center for Medicare and Medicaid Services (CMS) began reducing Medicare payments for Inpatient Prospective Payment System hospitals with excess readmissions. Excess readmissions are measured by a ratio, by dividing a hospital’s number of “predicted” 30-day readmissions for heart attack, heart failure, and pneumonia by the number that would be “expected,” based on an average hospital with similar patients. A ratio greater than 1 indicates excess readmissions.
In this exercise, you will:
More instructions provided below. Include your work in this notebook and submit to your Github account.
In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import bokeh.plotting as bkp
import seaborn as sns
from mpl_toolkits.axes_grid1 import make_axes_locatable
%matplotlib inline
sns.set_style('white')
In [2]:
# read in readmissions data provided
hospital_read_df = pd.read_csv('data/cms_hospital_readmissions.csv')
In [3]:
# deal with missing and inconvenient portions of data
clean_hospital_read_df = hospital_read_df[(hospital_read_df['Number of Discharges'] != 'Not Available')]
clean_hospital_read_df.loc[:, 'Number of Discharges'] = clean_hospital_read_df['Number of Discharges'].astype(int)
clean_hospital_read_df = clean_hospital_read_df.sort('Number of Discharges')
In [4]:
# generate a scatterplot for number of discharges vs. excess rate of readmissions
# lists work better with matplotlib scatterplot function
x = [a for a in clean_hospital_read_df['Number of Discharges'][81:-3]]
y = list(clean_hospital_read_df['Excess Readmission Ratio'][81:-3])
fig, ax = plt.subplots(figsize=(8,5))
ax.scatter(x, y,alpha=0.2)
ax.fill_between([0,350], 1.15, 2, facecolor='red', alpha = .15, interpolate=True)
ax.fill_between([800,2500], .5, .95, facecolor='green', alpha = .15, interpolate=True)
ax.set_xlim([0, max(x)])
ax.set_xlabel('Number of discharges', fontsize=12)
ax.set_ylabel('Excess rate of readmissions', fontsize=12)
ax.set_title('Scatterplot of number of discharges vs. excess rate of readmissions', fontsize=14)
ax.grid(True)
fig.tight_layout()
A. Initial observations based on the plot above
B. Statistics
C. Conclusions
D. Regulatory policy recommendations
Include your work on the following in this notebook and submit to your Github account.
A. Do you agree with the above analysis and recommendations? Why or why not?
B. Provide support for your arguments and your own recommendations with a statistically sound analysis:
You can compose in notebook cells using Markdown:
In [5]:
# A.1 I don't find that it trends down.
# To me the line looks almost flat. There is also a 95% confidence interval surrounding, which is hardly seen.
sns.regplot(data=clean_hospital_read_df, x='Number of Discharges', y='Excess Readmission Ratio', line_kws={'color': 'red'})
plt.xlim([0, max(x)])
plt.ylim([0, max(y)])
Out[5]:
In [6]:
# A.2 I based my conclusions on the red and green area as was stated.
# The red area has a readmission ratio of above 1.15 and less than 350 discharges.
# It's all around 5%, but the incidence rate of above 1.15 readmission ratio's is actually slightly lower below 350 discharges.
print('Above 1.15:\n')
incidence_overall = sum(clean_hospital_read_df['Excess Readmission Ratio'] > 1.15) / len(clean_hospital_read_df['Excess Readmission Ratio'])
incidence_lowdischarge = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 350]['Excess Readmission Ratio'] > 1.15) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 350]['Excess Readmission Ratio']))
incidence_highdischarge = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 800]['Excess Readmission Ratio'] > 1.15) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 800]['Excess Readmission Ratio']))
print('overall:', incidence_overall)
print('low:', incidence_lowdischarge)
print('high:', incidence_highdischarge)
In [7]:
# A.3 The green area has a readmission ratio of below 0.95 and more than 800 discharges.
# It went from overall 24% to 34% for the high nr of discharges. Hence here they are right with their statement.
print('Below 0.95:\n')
incidence_overall = sum(clean_hospital_read_df['Excess Readmission Ratio'] < 0.95) / len(clean_hospital_read_df['Excess Readmission Ratio'])
incidence_lowdischarge = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 350]['Excess Readmission Ratio'] < 0.95) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 350]['Excess Readmission Ratio']))
incidence_highdischarge = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 800]['Excess Readmission Ratio'] < 0.95) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 800]['Excess Readmission Ratio']))
print('overall:', incidence_overall)
print('low:', incidence_lowdischarge)
print('high:', incidence_highdischarge)
In [8]:
# B.1 They are right about the readmission rate being 1.023.
# They are wrong about the 63%. It's 59%.
mean = clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 100]['Excess Readmission Ratio'].mean()
percentage = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 100]['Excess Readmission Ratio'] > 1) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] < 100]['Excess Readmission Ratio'])) * 100
print(mean)
print(percentage)
In [9]:
# B.2 They are right about both statements: mean 0.978 and 44% above 1.
mean = clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 1000]['Excess Readmission Ratio'].mean()
percentage = (sum(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 1000]['Excess Readmission Ratio'] > 1) /
len(clean_hospital_read_df[clean_hospital_read_df['Number of Discharges'] > 1000]['Excess Readmission Ratio'])) * 100
print(mean)
print(percentage)
In [10]:
# C.1 As mentioned before the line in the regression plot looks almost flat, so can't imagine that it's a big correlation.
# They don't mention what the size of the correlation is. It could be that it's a very small correlation,
# but due to the huge sample size that it is significant, but a very small correlation is not very relevant.
# When I calculate the correlation, I get 'nan' since there are NAN values in the dataset!
# These rows should be excluded of any analysis. This goes also for everything above here.
from scipy.stats import pearsonr
pearsonr(clean_hospital_read_df['Number of Discharges'], clean_hospital_read_df['Excess Readmission Ratio'])
Out[10]:
In [11]:
# C.2 Can't prove that with the data at hand.
# So far I don't see any indication that there is a big significant correlation between hospital size and readmission ratio.
In [12]:
# D.1 & D.2 Since there is no evidence of a problem, new regulation are premature.
In [13]:
# Hospitals/facilities with small capacity (<300) have a different readmission ratio.
# H0: They don't. H1: They have.
# Also check correlation.
In [14]:
# First we exclude everything with a NAN value
print(sum(clean_hospital_read_df['Excess Readmission Ratio'].isnull()))
print(clean_hospital_read_df.dropna(subset=['Excess Readmission Ratio']).shape)
print(clean_hospital_read_df.shape)
hospital_df = clean_hospital_read_df.dropna(subset=['Excess Readmission Ratio'])
In [15]:
# Significantly different readmission ratio mean. Hence H0 rejected (easily below 0.01)
# But the difference is very very small.
# Effect-size is very important with these large datasets.
from scipy.stats import ttest_ind
print(ttest_ind(hospital_df[hospital_df['Number of Discharges'] < 300]['Excess Readmission Ratio'],
hospital_df[hospital_df['Number of Discharges'] >= 300]['Excess Readmission Ratio']))
print(hospital_df[hospital_df['Number of Discharges'] < 300]['Excess Readmission Ratio'].mean())
print(hospital_df[hospital_df['Number of Discharges'] >= 300]['Excess Readmission Ratio'].mean())
In [16]:
# We see also a very significant correlation, but as I expected the value is only -0.097.
# Usually we start speeking of an interesting correlation from 0.7 and above or -0.7 and below.
from scipy.stats import pearsonr
pearsonr(hospital_df['Number of Discharges'], hospital_df['Excess Readmission Ratio'])
Out[16]:
In [17]:
# From the hypothesis and p-value we should conclude that the readmission ratio in hospital/facilities with small capacity is
# significantly different. Nevertheless, for the purpose of cutting their money and making them jump through hoops
# to defend that their quality is good enough the difference is way not enough. Due to the large dataset even
# really small values become significant. Even though they are not interesting for the purpose.
# Always check effectsize of the difference!